package cn.bdqn.controller;

import cn.bdqn.pojo.Books;
import cn.bdqn.service.BooksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class BooksController {

    @Autowired
    private BooksService booksService;

    @RequestMapping("/bfindAll")
    public String findAll(Model model) {
        System.out.println("表现层：查询有所图书");
        List<Books> list = booksService.findAll();
        model.addAttribute("list", list);
        for (Books books:list) {
            System.out.println("扇贝丽"+books.getBookName());
        }
        //return "forward:index.jsp";//转发到页面
        return "list";
    }

    @RequestMapping("/criteriaQuery")
    public String criteriaQuery(Model model,String bookName,String bookAuthor,String bookPublish){
        System.out.println("表现层：动态条件查询");
        List<Books> list=booksService.criteriaQuery(bookName,bookAuthor,bookPublish);
        model.addAttribute("list",list);
        for (Books books:list) {
            System.out.println("扇贝丽"+books.getBookName());
        }
        return "list";
    }

}
